package pers.cj.pdos.controller.entity;

import java.util.List;

/**
 * 响应table请求数据的json包
 */
public class ResponseList {
    /**
     * 0-成功 其他-失败
     */
    private int code;
    private String message;
    private List data;
    private long count;

    public ResponseList() {
    }

    public ResponseList(int code, String message, List data, long count) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.count = count;
    }

    public static ResponseList success(long count, List data){
        ResponseList entity = new ResponseList();
        entity.setCode(0);
        entity.setMessage("处理成功");
        entity.setCount(count);
        entity.setData(data);
        return entity;
    }

    public static ResponseList fail(String msg){
        ResponseList entity = new ResponseList();
        entity.setCode(1);
        entity.setMessage("处理成功");
        entity.setCount(0);
        entity.setData(null);
        return entity;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public List getData() {
        return data;
    }

    public long getCount() {
        return count;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(List data) {
        this.data = data;
    }

    public void setCount(long count) {
        this.count = count;
    }
}
